import requests
import re

# 模拟登录
url = "https://vip.hdbz.net/auth/ajaxlogin"
session = requests.Session()
# ajax函数对应传值
response = session.post(url, data={"username": "15703822596", "userpwd": "Wert123"})
print(response)
print(response.cookies)

# # 获取我的收藏
# favorites_url = 'https://vip.hdbz.net/site/FavoriteList?page=1&limit=10'
# favorites_response = session.get(favorites_url)
# if favorites_response.status_code == 200:
#     favorites_json = favorites_response.json()
#     for favorite in favorites_json['data']:
#         print(favorite)


# 添加收藏
# add_favorites_url = 'https://vip.hdbz.net/site/ImageStore'
# add_favorites_response = session.post(add_favorites_url, data= {"aid": "179048", "imageurl": "/wallpaper/202510/179048.html"})
# print(add_favorites_response.status_code)

# # 添加多个收藏
# url='https://www.hdbz.net/'
# response = requests.get(url)
# if response.status_code == 200:
#     response_text = response.content.decode('utf-8')
#     pic_list = re.findall(r'<a href="(/wallpaper/\d{6}/\d{6}.html)".*?title="(.*?)" data-resolution=".*?".*?data-original="(.*?)".*?<div class="resolution">(.*?)</div>.*?</a>', response_text, re.S)
#     for pic in pic_list:
#         data = {
#             "aid": pic[0][-11:-5],
#             "imageurl": pic[0],
#         }
#         add_favorites_url = 'https://vip.hdbz.net/site/ImageStore'
#         add_favorites_response = session.post(add_favorites_url, data=data)


